#pragma strict
import System.IO;
import System.Collections.Generic;
/////////////////////////////////////////////////////////////////////////////
/// PlayerAnimConfig 解析器,解析,Assets/Level4/Configs/PlayerAnimConfig.txt
/// 供 AnimCreator使用.
/////////////////////////////////////////////////////////////////////////////
class AnimConfigParser{
	static var PATH:String = "Assets/Level4/Configs/PlayerAnimConfig.txt";
	static var isDebug:boolean = true;
	private var list:List.<AnimConfig> = new List.<AnimConfig>();
	/** 解析 */
	function Parse(){
		list.Clear();
		if(File.Exists(PATH)){
			var lines:String[] = File.ReadAllLines(PATH);
			for(var line:String in lines){
				if(line.Contains("//") || String.IsNullOrEmpty(line))
					continue;
				var texts:String[] = line.Split(" "[0]);
				var name:String = texts[0].Trim();
				var normalizedTime:float = float.Parse(texts[1].Trim());
				var eventName:String = texts[2].Trim();
				list.Add(new AnimConfig(name,normalizedTime,eventName));
				
				if(isDebug)
					Debug.Log(line +":"+texts.length);
			}
		}
	}
	/** 获取 一组 */
	function GetAll(name:String){
		return list.FindAll(function(config:AnimConfig){
			return config.name == name;
		});
	}
	
	function Dispose(){
		list.Clear();
	}
}

